<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input type="text" name="shuru" id="shuru" value="" />
		<input type="button" id="res" value="=" />
		<input type="button" class="btn" value="1" />
		<input type="button" class="btn" value="2" />
		<input type="button" class="btn" value="3" />
		<input type="button" class="btn" value="4" />
		<input type="button" class="btn" value="5" />
		<input type="button" class="btn" value="+" />
		<input type="button" class="btn" value="/" />
		<input type="button" class="btn" value="-" />
		<input type="button" class="btn" value="*" />
	</body>
	<script type="text/javascript">
		var shuru = document.querySelector("#shuru");
		var res = document.querySelector("#res");
		var btn = document.querySelectorAll(".btn");
		var str = "";
		for (var i=0;i<btn.length;i++) {
			btn[i].onclick = function(){
				str += this.value;
				shuru.value = str;
			}
		}
		
		res.onclick = function(){
			shuru.value = eval(str);	
			str = eval(str);
		}
		
	</script>
</html>
